/*
 *  MWArgs.cpp
 *  ModMaxwell
 *
 *  Created by Michael Barriault on 10-10-18.
 *  Copyright 2010 MikBarr Studios. All rights reserved.
 *
 */

#include "MW.h"
#include <T3nsors/Macros.h>
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

void MW::Args(std::vector<std::string> argv) {
//	int a = 0;
	for ( unsigned int i=0; i<argv.size(); i++ ) switch ( (char)argv[i][0] ) {
		case 'i':
			id = (string)argv[i+1];
			i++;
			break;
		case 'n':
			n = stoi(argv[i].erase(0,1));
			break;
		case 'T':
			T = stof(argv[i].erase(0,1));
			break;
		case 's':
			s = stof(argv[i].erase(0,1));
			break;
		case 'e':
			epsilon = stof(argv[i].erase(0,1));
			break;
		case 'k':
			K = stof(argv[i].erase(0,1));
			break;
		case 'j':
			I = stof(argv[i].erase(0,1));
			break;
		case 'c':
			c = stof(argv[i].erase(0,1));
			break;
        case 'W':
            Omega = stof(argv[i].erase(0,1));
            break;
        case 'U':
            pole = stoi(argv[i].erase(0,1));
            break;
		case 'p':
			FORa p(a) = stof(argv[++i]);
/*			FOR(j,argv[i].length()) {
				if ( (char)argv[i][j] == '-' ) {
					p(a) = -1;
					a++;
					j++;
				}
				else if ( (char)argv[i][j] == '0' ) {
					p(a) = 0;
					a++;
				}
				else if ( (char)argv[i][j] == '1' ) {
					p(a) = 1;
					a++;
				}
			}*/
			//O.p(a) = int(argv[i][a+1]-48);
			//FORa if ( O.p(a) > 1 ) O.p(a) = 1;
			break;
		case 'h':
			Params(cout);
			exit(0);
	}
}

void MW::Params(std::ostream& out) {
	out << id << endl;
	out << "n = " << n << "\t\t\tNumber of points in x\n";
	out << "s = " << s << "\t\tRatio of timestep to spacestep\n";
	out << "T = " << T << "\t\t\tEvolution period\n";
	out << "e = " << epsilon << "\t\tDissipation parameter\n";
	out << "k = " << K << "\t\t\tDivergence constraint damping parameter\n";
	out << "j = " << I << "\t\t\tForce-free constraint damping parameter\n";
	out << "p = ";
	FORa out << p(a) << ",";
	out << "\t\tBoundary type\n";
	out << "c = " << c << "\t\t\tConstraint violation\n";
	out << "Omega = " << Omega << "\t\tBackground rotation rate\n";
	out << "Pole = " << pole << "\t\t0->pole, 1->equator\n";
	out << "Current constraint enforcement.\n";
}
